package com.example.lol.adapter;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;

import com.example.lol.base.BaseVpAdapter;
import com.example.lol.bean.NewsTypeBean;
import com.example.lol.ui.fragment.EightFragment;
import com.example.lol.ui.fragment.FiveFragment;
import com.example.lol.ui.fragment.FourFragment;
import com.example.lol.ui.fragment.SevenFragment;
import com.example.lol.ui.fragment.SixFragment;
import com.example.lol.ui.fragment.ThreeFragment;
import com.example.lol.ui.fragment.TwoFragment;
import com.example.lol.ui.news.NewsArticleFragment;

public class NewsVpAdapter extends BaseVpAdapter<NewsTypeBean> {

    public NewsVpAdapter(@NonNull FragmentManager fm) {
        super(fm);
    }

    @Override
    protected Fragment createFragment(int position) {
        Fragment fragment = null;
        NewsTypeBean bean = getData(position);
        if (bean.getType() == NewsTypeBean.TYPE_ARTICLE) {
            fragment = new NewsArticleFragment();
        }
        if (bean.getType() == NewsTypeBean.TYPE_TWO) {
            fragment = new TwoFragment();
        }
        if (bean.getType() == NewsTypeBean.TYPE_THREE) {
            fragment = new ThreeFragment();
        }
        if (bean.getType() == NewsTypeBean.TYPE_FOUR) {
            fragment = new FourFragment();
        }
        if (bean.getType() == NewsTypeBean.TYPE_FIVE) {
            fragment = new FiveFragment();
        }
        if (bean.getType() == NewsTypeBean.TYPE_SIX) {
            fragment = new SixFragment();
        }
        if (bean.getType() == NewsTypeBean.TYPE_SEVEN) {
            fragment = new SevenFragment();
        }
        if (bean.getType() == NewsTypeBean.TYPE_EIGHT) {
            fragment = new EightFragment();
        }
        return fragment;
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return getData(position).getTitle();
    }
}

